﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BusinessLogicLayer.DataObject
{
    public class Message
    {
        public string ID { get; set; }
        public string MessageID { get; set; }
        public string EditorUserID { get; set; }
        public string EditorUserName { get; set; }
        public string Sender { get; set; }
        public string MessageContent { get; set; }
        public string Description { get; set; }
        public string Timestamp { get; set; }
        public string BackColor { get; set; }

        public Message(DataAccessLayer.Message Message)
        {
            this.ID = Message.ID.ToString();
            this.MessageID = Message.MessageID.ToString();
            this.EditorUserID = Message.EditorUserID.ToString();
            this.EditorUserName = Message.sUser.Users.Last().Username;
            this.Sender = Message.Sender;
            this.MessageContent = Message.Message1;
            this.Description = Message.Description;
            this.Timestamp = Message.Timestamp.ToHijriSolarString();
            if (Message.Announce)
                this.BackColor = Message.IsDeleted ? "#FF5555" : "#FFFFFF";
            else
                this.BackColor = Message.IsDeleted ? "#FF5555" : "#5555FF";
        }

        public static List<Message> Convert(List<DataAccessLayer.Message> Messages)
        {
            return (Messages.ConvertAll(new Converter<DataAccessLayer.Message, Message>(p => (new Message(p)))));
        }
    }
}
